<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ContactUs_Controller extends CI_Controller {
	
	function __construct()
    {
		parent::__construct();
		$this->load->model('contactus_model');
    }
	
	public function index()
	{
		$this->show_contactus_form();
	}
	
	public function show_contactus_form()
	{
		
		$this->html_meta['robots'] = 'nofollow,noindex';
		
		$this->template->write_view('header', 'header_detail_block', NULL, FALSE);
		$this->javascript_head = array
		(
			 '/script/menu.js' 
			,'/script/jquery-1.6.2.min.js'
			,'/script/jquery.validate.js'
			,'/script/config.js'
			,'/script/common-custom.js'
			,'/script/json2.js'
		);

		$this->template->write_view('content', 'contactus_block', NULL, FALSE);
		
		$this->render_template = TRUE;	
	}
	
	public function ajax_add_contactus()
	{
		$request_data = json_decode($_POST['request_data']);
		
		// add contact us
		$contact_us['subject'] =  $request_data->subject;
		$contact_us['contact_us_by_user_email'] =  $request_data->email;
		$contact_us['comment'] =  $request_data->comment;
		// $contact_us['contact_us_by_user_id'] =  $request_data->contact_us_by_user_id;
		$contact_us['contact_us_date'] =  date('Y-m-d H:m:s');
		// $contact_us['contact_us_by_user_ip'] =  $request_data->contact_us_by_user_ip;
		
		$response->result = $this->contactus_model->add_contact_us($contact_us);
		$response->status = ($response->result == TRUE ? 200 : 500);
		echo json_encode($response);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/article_controller.php */